﻿@model IList<HZU.ZP.Domain.Model.Notice>
@{
    switch (User.Claims.ToList()[2].Value)
    {
        case "Admin":
            Layout = "_AdminLayout";
            break;
        case "Company":
            Layout = "_CompanyLayout";
            break;
        case "Applicant":
            Layout = "_ApplicatLayout";
            break;
    }
}

<script>
    $(document).ready(function () {
        $(".eee").mouseover(function () {
            $(this).css({ "background-color": "gainsboro" });
        }).mouseout(function () {
            $(this).css({ "background-color": "" });
        });
        $("button#delete").click(function () {
            if (confirm("确实要删除吗？")) {
                $.ajax({
                    type: 'post',
                    url: '/Notice/DeleteNotice',
                    data: 'id=' + $(this).data("id"),
                    success: function (message) {
                        if (message.returnCode == "001") {
                            alert("删除成功！");
                            location.reload();
                        }
                    }
                });
            }
            else {
            }
        });
    });
</script>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-4 column">
            <a href="/Notice/AddNotice" class="btn btn-default btn-warning btn-block">新增公告</a>
        </div>
        <div class="col-md-4 column"></div>
        <div class="col-md-4 column"></div>
    </div>
    <br />
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="row clearfix">
                <div class="col-md-8 column">
                    <span>公告标题</span>
                </div>
                @if (User.Claims.ToList()[2].Value == "Admin")
                {
                <div class="col-md-4 column">
                    <span>操作</span>
                </div>
                }
            </div>
            @if (Model.Count() > 0)
            {
                foreach (var not in Model)
                {
                    <div class="eee">
                        <div class="row clearfix">
                            <div class="col-md-8 column">
                                <h4><a href="/Notice/GetNotice?noticeId=@not.Id&email=@User.Identity.Name">@not.Title</a></h4>
                            </div>
                            @if (User.Claims.ToList()[2].Value == "Admin")
                            {
                                <div class="col-md-4 column">
                                    <a href="/Notice/UpdateNotice?id=@not.Id" class="btn btn-default btn-link">编辑</a>
                                    &thinsp;
                                    <button id="delete" type="button" class="btn btn-default btn-link" data-id="@not.Id">删除</button>
                                </div>
                            }
                        </div>
                    </div>
                }
            }
            else
            {
                <h4 style="height:300px;text-align:center">无数据。。。</h4>
            }
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div style="text-align: center;">
                <ul class="pagination">
                    @for (int i = (int)ViewData["PageIndex"] - 2 <= 0 ? 1 :(int)ViewData["PageIndex"] - 2; i < (int)ViewData["PageIndex"]; i++)
                    {
                        <li><a href="/Notice/NoticeList?pageIndex=@i">@i</a></li>
                    }
                    @if ((int)ViewData["PageIndex"] > 0)
                    {
                        <li><a href="javascript:;" style="background-color:LightGrey">@((int)ViewData["PageIndex"])</a></li>
                    }
                    @for (int i = (int)ViewData["PageIndex"] + 1; i <= (int)ViewData["PageCount"] && i < (int)ViewData["PageIndex"] + 2; i++)
                    {
                        <li><a href="/Notice/NoticeList?pageIndex=@i">@i</a></li>
                    }
                    <li><a style="border :none;background-color:white">&nbsp;&nbsp;&nbsp;&nbsp;共@((int)ViewData["PageCount"])页</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>